import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { UserType } from '@/types/user'
export const userInfo = defineStore(
  'user',
  () => {
    const user = ref<UserType>()
    // 存用户信息
    const setUser = (u: UserType) => (user.value = u)

    // 删除用户信息
    const delUser = () => (user.value = undefined)
    return { user, setUser, delUser }
  },
  {
    // 数据持久化存储
    persist: true
  }
)
